package com.conn;

import java.io.*;
import com.conn.*;

class ParseInfo {
    Command cmdid;
    Object o;
}

public abstract class Parser {
    public boolean parse(byte[] data, int len, ParseInfo p) {
        Command id = getCommandId(data, len);
        switch (id) {
            case REGISTER:
                p.cmdid = id;
                System.out.println("get REGISTER command");
                p.o = registerUnpack(data, len);
                break;
            case LOGIN:
                System.out.println("hi LOGIN");
                break;
        }

        return null == p.o? false:true;
    }
    public abstract Command getCommandId(byte[] data, int len);
    public abstract RegisterInfo registerUnpack(byte[] data, int len);
};
